import { createRouter, createWebHistory } from 'vue-router'
import { createRouterGuards } from './routerGuards'

const router = createRouter({
  history: createWebHistory(),
  strict: true,
  routes: [
    {
      path: '/',
      name: 'index',
      redirect: '/chat/new',
    },
    {
      path: '/chat',
      name: 'chat',
      redirect: '/chat/new',
      component: ()=> import('@/views/pages/chat/chat.vue'),
      children: [
        {
          path: '/chat/:id',
          name: 'message',
          component: () => import('@/views/pages/chat/message.vue'),
        }
      ]
    }
  ],
})

export function setupRouter (app) {
  app.use(router)
  // 创建路由守卫
  createRouterGuards(router)
}

export default router
